package org.nokatag.dbgrid;

import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;

import javax.servlet.FilterConfig;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.nokatag.system.Concest;

public class NDBGridCellsGet {
	/**
	 * <p>@Description 保存设置</p>
	 * <p>author rebin </p>
	 * <p>@Time 上午1:01:14</p>
	 * <p>xiefangjian@163.com</p>
	 * @param request
	 * @param response
	 * @param config
	 */
	public void getCells(HttpServletRequest request,HttpServletResponse response,FilterConfig config){
		String cells = request.getParameter("nkdbgridcells");
		String key = request.getParameter("nkdbgridkey");
		//--------------保存设置-------------------------------
		if(null!=cells && null!=key){
			NDBGridCellsDBUtil ndb = new NDBGridCellsDBUtil();
			ndb.CeeateFileTable(request);
			ndb.SaveSet(key, cells,request);
		}
		//--------------输出----------------------------------
		try{
			OutputStream out = response.getOutputStream();
			Writer wr=new OutputStreamWriter(out,Concest.ENCODING);
			wr.write("1");
			wr.flush();
			out.flush();
			wr.close();
			out.close();
		}catch(Exception se){}
	}
	
	/**
	 * <p>@Description 清除配置</p>
	 * <p>author rebin </p>
	 * <p>@Time 上午2:18:21</p>
	 * <p>xiefangjian@163.com</p>
	 * @param request
	 * @param response
	 * @param config
	 */
	public void clearSet(HttpServletRequest request,HttpServletResponse response,FilterConfig config){
		String key = request.getParameter("nkdbgridkey");
		//--------------保存设置-------------------------------
		if(null!=key){
			NDBGridCellsDBUtil ndb = new NDBGridCellsDBUtil();
			ndb.CeeateFileTable(request);
			ndb.ClearSet(key,request);
		}
		//--------------输出----------------------------------
		try{
			OutputStream out = response.getOutputStream();
			Writer wr=new OutputStreamWriter(out,Concest.ENCODING);
			wr.write("1");
			wr.flush();
			out.flush();
			wr.close();
			out.close();
		}catch(Exception se){}
	}
	//===================折行设置=====================================================================
	/**
	 * <p>@Description 清除折行设置</p>
	 * <p>author rebin </p>
	 * <p>@Time 下午3:55:16</p>
	 * <p>xiefangjian@163.com</p>
	 * @param request
	 * @param response
	 * @param config
	 */
	public void clearFoldingLine(HttpServletRequest request,HttpServletResponse response,FilterConfig config){
		String key = request.getParameter("nkdbgridkey");
		//--------------保存设置-------------------------------
		if(null!=key){
			NDBGridCellsDBUtil ndb = new NDBGridCellsDBUtil();
			ndb.CeeateFileTable(request);
			ndb.SaveFoldingLine(key,request,false);
		}
		//--------------输出----------------------------------
		try{
			OutputStream out = response.getOutputStream();
			Writer wr=new OutputStreamWriter(out,Concest.ENCODING);
			wr.write("1");
			wr.flush();
			out.flush();
			wr.close();
			out.close();
		}catch(Exception se){}
	}
	/**
	 * <p>@Description 添加折行设置</p>
	 * <p>author rebin </p>
	 * <p>@Time 下午3:55:04</p>
	 * <p>xiefangjian@163.com</p>
	 * @param request
	 * @param response
	 * @param config
	 */
	public void getFoldingLine(HttpServletRequest request,HttpServletResponse response,FilterConfig config){
		String key = request.getParameter("nkdbgridkey");
		//--------------保存设置-------------------------------
		if(null!=key){
			NDBGridCellsDBUtil ndb = new NDBGridCellsDBUtil();
			ndb.CeeateFileTable(request);
			ndb.SaveFoldingLine(key,request,true);
		}
		//--------------输出----------------------------------
		try{
			OutputStream out = response.getOutputStream();
			Writer wr=new OutputStreamWriter(out,Concest.ENCODING);
			wr.write("1");
			wr.flush();
			out.flush();
			wr.close();
			out.close();
		}catch(Exception se){}
	}
	
}
